package concurrensy.producer_consumer;

public class Consumer implements Runnable {

	private final RingBuffer buffer;
	private final long timeout;

	public Consumer(RingBuffer buffer, long timeout) {
		this.buffer = buffer;
		this.timeout = timeout;
	}

	@Override
	public void run() {
		while(true) {
			buffer.getProduct();
			try {
				Thread.sleep(timeout);
			} catch (InterruptedException e) {
				e.printStackTrace();
				return;
			}
		}
	}

}
